<?php

namespace frontend\actions;

use common\CacheKey;
use common\Common;
use yii\data\ActiveDataProvider;
use yii\data\DataFilter;
use yii\helpers\ArrayHelper;
use yii\rest\IndexAction;

class ProductIndexAction extends IndexAction
{
    public function run(): null|ActiveDataProvider|DataFilter
    {
        $params=\Yii::$app->getRequest()->getQueryParams();
        if(!isset($params['cate_id'])){

        }
        $cateId = \Yii::$app->redis->hget(CacheKey::PRODUCT_CATE_IDS_HASH,intval($params['cate_id']));
        \Yii::$app->getRequest()->setQueryParams(ArrayHelper::merge(
            \Yii::$app->getRequest()->getQueryParams(),
            [
                'filter' => [
                    'user_id' => intval(\Yii::$app->user->identity->getId()),
                ],
            ]
        ));
        return parent::run();
    }
}